#pragma once
#include <google/protobuf/stubs/callback.h>
#include <functional>
#include <memory>
namespace fastrpc::rpc {
class FastRpcClosure : public google::protobuf::Closure {
public:
    typedef std::shared_ptr<FastRpcClosure> ptr;
    explicit FastRpcClosure(std::function<void()> cb) : m_cb(cb) {}

    ~FastRpcClosure() = default;

    void Run() {
        if (m_cb) {
            m_cb();
        }
    }

private:
    std::function<void()> m_cb{nullptr};
};
}  // namespace fastrpc::rpc